package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Supplier;
import com.atguigu.jxc.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/supplier")
public class SupplierController {

    @Autowired
    private SupplierService supplierService;

    /**
     * 分页查询供应商
     * @param page
     * @param rows
     * @param supplierName
     * @return
     */
    @PostMapping("/list")
    @ResponseBody
    public Map<String,Object> list(Integer page,Integer rows,String supplierName){
       return supplierService.list(page,rows,supplierName);
    }


    @PostMapping("/save")
    @ResponseBody
    public ServiceVO saveOrUpdate(Supplier supplier){

        return supplierService.saveOrUpdate(supplier);
    }

    @PostMapping("/delete")
    @ResponseBody
    public ServiceVO delete(String[] ids){
        return supplierService.delete(ids);
    }
}
